import request from '@/utils/request'

export function apiGetList(params, loading) {
  return request({
    url: `/permission/roleController/list`,
    method: 'get',
    params,
    loading,
    autoUntie: false,
  })
}
export function apiAdd(data) {
  return request({
    url: '/permission/roleController/add',
    method: 'post',
    data: data,
  })
}
export function apiEdit(data) {
  return request({
    url: '/permission/roleController/edit',
    method: 'put',
    data: data,
  })
}
export function apiDel(ids) {
  return request({
    url: '/permission/roleController/' + ids,
    method: 'delete',
  })
}

export function apiGetMenuList(params) {
  return request({
    url: '/permission/menuController/listMenuUnRoot',
    method: 'get',
    params,
    resField: 'data',
  })
}
// 根据角色获取勾选的菜单
export function apiGetMenuListByRole(ids) {
  return request({
    url: '/permission/rolePermissionController/listTargets?sourceIds=' + ids,
    method: 'get',
    resField: 'data',
  })
}

// 关联角色
export function apiRelationMenu(data, loading) {
  return request({
    url: '/permission/rolePermissionController/addLink',
    method: 'post',
    data,
    loading,
  })
}

// 获取用户
export function apiGetUserList(data, loading) {
  return request({
    url: '/permission/userController/list',
    method: 'get',
    data,
    loading,
  })
}

// 根据角色获取勾选的用户
export function apiGetUserListByRole(ids, loading) {
  return request({
    url: '/permission/roleUserController/listTargets?sourceIds=' + ids,
    method: 'get',
    loading,
    resField: 'data',
  })
}

// 关联用户
export function apiRelationUser(data, loading) {
  return request({
    url: '/permission/roleUserController/addLink',
    method: 'post',
    data,
    loading,
  })
}

